package com.rw.coco.handler.message.event;

import com.rw.coco.api.data.CocoDataApi;
import com.rw.coco.api.event.MessageEvent;
import com.rw.coco.api.event.PrivateMessageEvent;
import com.rw.coco.api.log.CocoLogger;
import com.rw.coco.api.reply.CocoReplyApi;
import com.rw.coco.util.CocoData;

/**
 * 可可私聊消息对象
 */
public class CocoPrivateMessageEvent extends CocoMessageEvent implements PrivateMessageEvent {
    private final PrivateMessageEvent privateMessage;

    public CocoPrivateMessageEvent(PrivateMessageEvent privateMessage, CocoDataApi dataApi,
                                   CocoReplyApi replyApi, CocoLogger logger, CocoData cocoData) {
        super(privateMessage, dataApi, replyApi, logger, cocoData);
        this.privateMessage = privateMessage;
    }

    @Override
    public boolean isBlack() {
        return !accountModel.getSuperAdmin() && accountModel.getBlackList();
    }

    @Override
    public MessageEvent getMessageEvent() {
        return getPrivateMessage();
    }

    public PrivateMessageEvent getPrivateMessage() {
        return privateMessage;
    }

    /**
     * 删除好友，如果是群临时会话则无效
     */
    public void delete() {
        getPrivateMessage().delete();
    }

    /**
     * 向群组发消息
     *
     * @param message 需要发送的消息
     * @param groupId 发送的群组ID
     */
    @Override
    public void sendGroup(String message, String groupId) {
        privateMessage.sendGroup(message, groupId);
    }
}
